From 41eae921c515d43ae303e8f023460d25e41625ed Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Thu, 30 May 2019 15:10:53 -0600 Subject: [PATCH] fix potential memory leaks. (#365) * fix potential memory leaks. * fix more memory leaks. A method to find these is to add -DQT_ASCII_CAST_WARNINGS and then look for xstrdup in the warnings. * a few cleanups clazy caught. --- g7towin.cc | 2 +- gdb.cc | 2 +- html.cc | 5 ++- navilink.cc | 2 +- ozi.cc | 4 +- reference/gc/GCGCA8_logs~html.txt | 64 +++++++++++++++++++++++++++++++ testo.d/text.test | 3 ++ tmpro.cc | 4 +- xcsv.cc | 7 +--- 9 files changed, 79 insertions(+), 14 deletions(-) create mode 100644 reference/gc/GCGCA8_logs~html.txt diff --git a/g7towin.cc b/g7towin.cc index ac1c15d9c..1e575cb1e 100644 --- a/g7towin.cc +++ b/g7towin.cc @@ -510,7 +510,7 @@ data_read() break; case 'L': - waypt_add_url(wpt, xstrdup(cdata), nullptr); + waypt_add_url(wpt, cdata, nullptr); break; default: diff --git a/gdb.cc b/gdb.cc index 9e948136a..5b1f95f0c 100644 --- a/gdb.cc +++ b/gdb.cc @@ -394,7 +394,7 @@ gdb_write_cstr_list(const char* str) static void gdb_write_cstr_list(const QString& str) { - return gdb_write_cstr_list(CSTRc(str)); + gdb_write_cstr_list(CSTRc(str)); } static void diff --git a/html.cc b/html.cc index 38df26bf2..144180ee4 100644 --- a/html.cc +++ b/html.cc @@ -215,11 +215,12 @@ html_disp(const Waypoint* wpt) if (html_encrypt && encoded) { s = rot13(logpart->cdata); } else { - s = xstrdup(logpart->cdata); + s = logpart->cdata; } - QString t = html_entitize(s); + char* t = html_entitize(s); gbfputs(t, file_out); + xfree(t); } gbfprintf(file_out, "
\n"); diff --git a/navilink.cc b/navilink.cc index 6f3f43155..b7df0c1b3 100644 --- a/navilink.cc +++ b/navilink.cc @@ -660,7 +660,7 @@ serial_read_routes(Waypoint** waypts) route_head* route = route_head_alloc(); route->rte_num = routedata[2]; - route->rte_name = xstrdup((char*)routedata + 4); + route->rte_name = (char*)routedata + 4; route_add_head(route); for (int sr = 0; sr < MAX_SUBROUTES; sr++) { diff --git a/ozi.cc b/ozi.cc index 964e4ab8d..e5f3d1a1d 100644 --- a/ozi.cc +++ b/ozi.cc @@ -903,7 +903,7 @@ ozi_waypt_pr(const Waypoint* wpt) } } else { /* no description available */ - shortname = xstrdup(""); + shortname = ""; } } else { shortname = csv_stringclean(wpt->shortname, BADCHARS); @@ -912,7 +912,7 @@ ozi_waypt_pr(const Waypoint* wpt) if (!shortname.isEmpty()) { description = csv_stringclean(shortname, BADCHARS); } else { - description = xstrdup(""); + description = ""; } } else { description = csv_stringclean(wpt->description, BADCHARS); diff --git a/reference/gc/GCGCA8_logs~html.txt b/reference/gc/GCGCA8_logs~html.txt new file mode 100644 index 000000000..e5bac5a79 --- /dev/null +++ b/reference/gc/GCGCA8_logs~html.txt @@ -0,0 +1,64 @@ + + + + +
+GCGCA8 - Oozy rat in a sanitary zoo
+
GCGCA8 - N35°55.300 W86°51.700 (16S 512480 3975269) |
+3 / 2 |
The cache is not at the coordinates above. These coords will get you to the correct park and within 1/2 mile of the cache. The cache is within 35 feet of the trail. It is not handicapped accessible. It is a nice walk in the woods that is practical for all ages. There is no space in the container for trading items. You should bring a writing stick and bug spray is recommended. +So if the cache isn't at the above coordinates, where is it? + +
+ Hint: There Is No Hint +
+Found it by littlepod on 2005-07-03
+Write note by robertlipe on 2005-04-29
+Found it by Big Bumblebee on 2005-04-18
+Write note by robertlipe on 2005-03-27
+Found it by Virtual Babe on 2004-12-27
+Write note by robertlipe on 2004-01-12
+Write note by robertlipe on 2003-10-04
+Write note by robertlipe on 2003-07-03 | |